home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH03 / SIMX86 / GETINPUT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-04-09  |  1.6 KB  |  79 lines

  1. unit Getinput;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls;
  8.  
  9. type
  10.   TInputForm = class(TForm)
  11.     Label1: TLabel;
  12.     HexInput: TEdit;
  13.     OKButton: TButton;
  14.     procedure HexInputChange(Sender: TObject);
  15.     procedure OKButtonClick(Sender: TObject);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   InputForm: TInputForm;
  24.   InputValue:word;
  25.  
  26. implementation
  27.  
  28. uses SIMx86p;
  29.  
  30. {$R *.DFM}
  31.  
  32. procedure TInputForm.HexInputChange(Sender: TObject);
  33. var isHex:boolean;
  34.     i:integer;
  35.        ch:char;
  36. begin
  37.  
  38.     isHex := length(HexInput.Text) >= 1;
  39.         for i := 1 to length(HexInput.Text) do
  40.             isHex := isHex and
  41.                      (HexInput.Text[i] in ['0'..'9', 'a'..'f', 'A'..'F']);
  42.  
  43.         if not isHex then
  44.         begin
  45.             HexInput.Color := clRed;
  46.                 MessageBeep($FFFF);
  47.  
  48.         end
  49.         else begin
  50.  
  51.             InputValue := 0;
  52.             for i := 1 to length(HexInput.Text) do
  53.                 begin
  54.  
  55.                     ch := upcase(HexInput.Text[i]);
  56.                     if ch in ['0'..'9'] then
  57.                         InputValue := InputValue shl 4 + (ord(ch) and $f)
  58.                     else InputValue := InputValue shl 4 + (ord(ch) and $f) + 9;
  59.                     HexInput.Color := clWhite;
  60.  
  61.                 end;
  62.         end;
  63.  
  64. end;
  65.  
  66. procedure TInputForm.OKButtonClick(Sender: TObject);
  67. begin
  68.  
  69.     if (HexInput.Color <> clRed) then
  70.         begin
  71.  
  72.             SIMx86Form.Input.Items.Add(HexInput.Text);
  73.             InputForm.Close;
  74.  
  75.         end;
  76. end;
  77.  
  78. end.
  79.